package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int[] nums = {1,4,5,9,11};
        int target = 0;
        System.out.println("请输入整数目标值");
        target = sc.nextInt();
        int[] ans = twoSum(nums,target);
        for (int i = 0; i < ans.length; i++) {
            System.out.print(ans[i] + " ");
        }
            System.out.println();
    }

    public static int[] twoSum(int[] nums, int target) {
        int[] ans = new int[2];
        int i = 0;
        int j = 0;
        for(i = 0; i < nums.length; i++){
            for(j = i + 1; j < nums.length; j++){
                if(target == nums[i] + nums[j]){
                    ans[0] = i;
                    ans[1] = j;
                    break;
                }
            }
        }
        return ans;
    }
}
